<?php
/* @var $this UserController */
/* @var $model User */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'user-form',
	'enableAjaxValidation'=>false,
	'enableClientValidation'=>true,
	'clientOptions'=>array(
		'validateOnSubmit'=>true,)	
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'username'); ?>
		<?php echo $form->textField($model,'username',array('size'=>10,'maxlength'=>10)); ?>
		<?php echo $form->error($model,'username'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'password'); ?>
		<?php echo $form->passwordField($model,'password',array('size'=>10,'maxlength'=>45)); ?>
		<?php echo $form->error($model,'password'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'batch'); ?>
		<?php echo $form->textField($model,'batch',array('size'=>6,'maxlength'=>5)); ?>
		<?php echo $form->error($model,'batch'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'fullname'); ?>
		<?php echo $form->textField($model,'fullname',array('size'=>45,'maxlength'=>45)); ?>
		<?php echo $form->error($model,'fullname'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'email'); ?>
		<?php echo $form->textField($model,'email',array('size'=>25,'maxlength'=>45)); ?>
		<?php echo $form->error($model,'email'); ?>
	</div>	

	<?php if(!(Yii::app()->user->restricted)): ?>	
	
		<div class="row">
			<?php echo $form->labelEx($model,'team'); ?>
			<?php echo $form->dropDownList($model,
										   'team',
										   CHtml::listData(Team::model()->findAll(),'idteam','short_name'),
										   array('empty'=>'','class'=>'dropteam')
										   ); ?>		
			<?php echo $form->error($model,'team'); ?>
		</div>

		<div class="row">
			<?php echo $form->labelEx($model,'restricted'); ?>
					<?php echo $form->dropDownList($model, 'restricted',
													array('1'=>'Yes',
														  '0'=>'No',
														  ),
													array('empty'=>'','class'=>'dropbinary'));?>			
			<?php echo $form->error($model,'restricted'); ?>
		</div>	
		
	<?php else:	?>	
	
		<div class="row">
			<?php echo $form->dropDownList($model,
										   'team',
										   CHtml::listData(Team::model()->findAll(),'idteam','short_name'),
										   array('empty'=>'','class'=>'dropteam','style'=> 'display:none')
										   ); ?>		
			<?php echo $form->error($model,'team'); ?>
		</div>

	<?php endif;	?>			

	<div class="row">
		<?php echo $form->labelEx($model,'enabled'); ?>
				<?php echo $form->dropDownList($model, 'enabled',
												array('1'=>'Yes',
													  '0'=>'No',
													  ),
												array('empty'=>'','class'=>'dropbinary'));?>			
		<?php echo $form->error($model,'enabled'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'idrole'); ?>
		<?php echo $form->dropDownList($model,
									   'idrole',
									   CHtml::listData(Role::model()->findAll(array('order'=>'name ASC','condition'=>'team_id= '.$model->team)),
													   'idrole','name'),
													   array('empty'=>'','class'=>'droprole')
									   ); ?>		

		<?php echo $form->error($model,'idrole'); ?>
	</div>
	
<br>
	<div class="buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->